package bma.common.netty;

import java.util.Map;

import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelSink;

import bma.common.langutil.pipeline.CommonPipeline;

public class NettyChannelPipeline implements CommonPipeline<ChannelHandler> {

	private ChannelPipeline pipeline;

	public NettyChannelPipeline(ChannelPipeline pipeline) {
		super();
		this.pipeline = pipeline;
	}

	public ChannelPipeline getPipeline() {
		return pipeline;
	}

	public void setPipeline(ChannelPipeline pipeline) {
		this.pipeline = pipeline;
	}

	@Override
	public void addFirst(String name, ChannelHandler handler) {
		pipeline.addFirst(name, handler);
	}

	@Override
	public void addLast(String name, ChannelHandler handler) {
		pipeline.addLast(name, handler);
	}

	@Override
	public void addBefore(String baseName, String name, ChannelHandler handler) {
		pipeline.addBefore(baseName, name, handler);
	}

	@Override
	public void addAfter(String baseName, String name, ChannelHandler handler) {
		pipeline.addAfter(baseName, name, handler);
	}

	@Override
	public void remove(ChannelHandler handler) {
		pipeline.remove(handler);
	}

	@Override
	public ChannelHandler remove(String name) {
		return pipeline.remove(name);
	}

	@Override
	public <T extends ChannelHandler> T remove(Class<T> handlerType) {
		return pipeline.remove(handlerType);
	}

	@Override
	public ChannelHandler removeFirst() {
		return pipeline.removeFirst();
	}

	@Override
	public ChannelHandler removeLast() {
		return pipeline.removeLast();
	}

	@Override
	public void replace(ChannelHandler oldHandler, String newName,
			ChannelHandler newHandler) {
		pipeline.replace(oldHandler, newName, newHandler);
	}

	@Override
	public ChannelHandler replace(String oldName, String newName,
			ChannelHandler newHandler) {
		return pipeline.replace(oldName, newName, newHandler);
	}

	@Override
	public <T extends ChannelHandler> T replace(Class<T> oldHandlerType,
			String newName, ChannelHandler newHandler) {
		return pipeline.replace(oldHandlerType, newName, newHandler);
	}

	@Override
	public ChannelHandler getFirst() {
		return pipeline.getFirst();
	}

	@Override
	public ChannelHandler getLast() {
		return pipeline.getLast();
	}

	@Override
	public ChannelHandler get(String name) {
		return pipeline.get(name);
	}

	@Override
	public <T extends ChannelHandler> T get(Class<T> handlerType) {
		return pipeline.get(handlerType);
	}

	public ChannelHandlerContext getContext(ChannelHandler handler) {
		return pipeline.getContext(handler);
	}

	public ChannelHandlerContext getContext(String name) {
		return pipeline.getContext(name);
	}

	public ChannelHandlerContext getContext(
			Class<? extends ChannelHandler> handlerType) {
		return pipeline.getContext(handlerType);
	}

	public void sendUpstream(ChannelEvent e) {
		pipeline.sendUpstream(e);
	}

	public void sendDownstream(ChannelEvent e) {
		pipeline.sendDownstream(e);
	}

	public Channel getChannel() {
		return pipeline.getChannel();
	}

	public ChannelSink getSink() {
		return pipeline.getSink();
	}

	public void attach(Channel channel, ChannelSink sink) {
		pipeline.attach(channel, sink);
	}

	public boolean isAttached() {
		return pipeline.isAttached();
	}

	public Map<String, ChannelHandler> toMap() {
		return pipeline.toMap();
	}

	@Override
	public void clear() {

	}
}
